import { ApiCall } from "tsrpc";
import { ReqWordTask_done, ResWordTask_done } from "../../../shared/master/word/PtlWordTask_done";
import { player } from "../../../model/fight/body/player";
import { template } from "../../../shared/master/MsgAction";

export default async function (call: ApiCall<ReqWordTask_done, ResWordTask_done>) {
    call.succ({})
    let user = call.req._player as player;
    let task = user.getWordTask();
    let _word = user.getPosition().getWord()
    if(!task){
        user.sendMsg(template.default_none,`ℹ️当前世界🌎[${_word.name}]还没有世界任务.`)
        return;
    }
    if(!task.end){
        task.notice();
        return;
    }
    let battle = user.get_battle();
    if(battle){
        user.sendMsg(template.default_none,'ℹ️战斗中无法提交世界任务.')
        return;
    }
    await task.done();
}